package com.xq

import rx.Observable
import java.io.File

/**
 * @author jltxseo
 *         Created by junlintianxia on 2017/06/14.
 */

fun main(args: Array<String>){
    val rootPath = ClassLoader.getSystemResource("").path
    val index = rootPath.indexOf("/build")
    if (index != -1) {
        val text = File(rootPath.substring(0, index) + "/src/main/Resources/input").readText()
        Observable.from(text.toCharArray().asIterable())
                .filter {
                    !it.isWhitespace()
                }.groupBy {
                    it
                }.map{
                    o->o.count().subscribe{
                        println("${o.key}-> ${it}")
                    }
                }
                .subscribe()
        println("text=>${text}")
    }

}
